
import hashlib
from util.log import Log

class Crypto:
    @staticmethod
    def md5(text: str) -> str:
        try:
            hash = hashlib.md5()
            hash.update(text.encode(encoding='utf-8'))
            res = hash.hexdigest()
            return res
        except Exception as e:
            raise e

# https://blog.csdn.net/weixin_50153843/article/details/131027348

    @staticmethod
    def fileMD5(file: bytes) -> str:
        try:
            hash = hashlib.md5()
            hash.update(file)
            md5_str = hash.hexdigest()
            return md5_str
        except Exception as e:
            raise e


